varying vec3 var_vec3_farRay;
varying vec2 var_vec2_texcoord0;
uniform sampler2D uni_sampler2D_normal;
uniform sampler2D uni_sampler2D_color;
uniform sampler2D uni_sampler2D_depth;

void main()
{
	float depth=texture2D(uni_sampler2D_depth,var_vec2_texcoord0).x;
	if(depth<1.0){
		vec4 normal=texture2D(uni_sampler2D_normal,var_vec2_texcoord0);
	    vec4 color=texture2D(uni_sampler2D_color,var_vec2_texcoord0);
		vec3 pos=var_vec3_farRay*depth;
		if(!gl_FrontFacing){
		    normal=-normal;
		}
	    normal.z=sqrt(1-normal.x*normal.x-normal.y*normal.y);
		gl_FragColor[0]=max(0.0,dot(normalize(-pos),normal));//fresnel
		gl_FragColor[1]=depth;
	}else{
	    discard;
	}
}
